/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import javax.swing.JTable;
import model.Login;
import utility.ConnectDB;


/**
 *
 * @author Dom
 */
public class ChangePassController {
    
    public static int  ChangePass(Login lg) throws SQLException
    {
        String sql = "SELECT COUNT(*) FROM DangNhap WHERE ID = '" + lg.getID() + "' AND Password = '" + lg.getPassword() +"'";
        System.out.println(sql);    
        ResultSet table = ConnectDB.getResultSet(sql);
            ResultSetMetaData rsmd = table.getMetaData();
            
            if(table != null && table.next())
            {
                sql = "UPDATE DangNhap SET Password ='" + lg.getCpass() +"' WHERE ID = '" + lg.getID() +"' ";
                 //System.out.println(sql);
                //return ConnectDB.ExecuteQueryString(sql);
            }
            return -1;
            
    }
}
